#include <string>

using namespace std;

class Solution {
public:

    //剑指 Offer 05. 替换空格
    string replaceSpace(string s) {
        string str;
        for (const auto& ch : s)
        {
            if (ch == ' ')
            {
                str += "%20";
            }
            else 
            {
                str += ch;
            }
        }
        return str;
    }
///////////////////////////////////////////////////

    //剑指 Offer 58 - II. 左旋转字符串
    string reverseLeftWords(string s, int n) {
        size_t old_size = s.size();
        s += s;
        return string(s, n, old_size);
    }
};

struct Node
{
    Node* _left;
    Node* _right;
    Node* _parent;
    int _bf;
};
void RotateR(Node* parent)
{
    Node *subL = parent->_left;
    Node *subLR = subL->_right;

    parent->_left = subLR;
    if (subLR != nullptr)
    {
        subLR->_parent = parent;
    }
    subL->_right = parent;
    

    Node *ppnode = parent->_parent;
    if (ppnode == nullptr)
    {
        subL->_parent = nullptr;
    }
    else
    {
        if (ppnode->_left == parent)
        {
            ppnode->_left = subL;
        }
        else if (ppnode->_right == parent)
        {
            ppnode->_right = subL;
        }
        subL->_parent = ppnode;
    }
    parent->_bf = subL->_bf = 0;

}

